The present invention relates generally to data processing environments and, more particularly, to accessing shared resources in a multi-user environment, such as a computer network system.
Computers are a powerful tool for the acquisition and processing of information. Computerized databases, which can be regarded as a kind of electronic filing cabinet or repository for collecting computerized data files, are particularly adept at processing vast amounts of information. As such, these systems serve to maintain information in database files or tables and make that information available on demand.
Between the actual physical database itself (i.e., the data actually stored on a storage device) and the users of the system, a database management system or DBMS is provided as a software cushion or layer. In essence, the DBMS shields the database user from knowing or even caring about underlying hardware-level details. Typically, all requests from users for access to the data are processed by the DBMS. For example, information may be added or removed from data files, information retrieved from or updated in such files, and so forth, all without knowledge of underlying system implementation. In this manner, the DBMS provides users with a conceptual view of the database that is removed from the hardware level. The general construction and operation of a database management system is known in the art. See e.g., Date, C., An Introduction to Database Systems, Volume I and II, Addison Wesley, 1990; the disclosure of which is hereby incorporated by reference.
Of particular interest to the present invention are those information processing systems which are operative in a shared fashion, i.e., by multiple users at a given time. A multi-user database implemented on a client/server platform is one such system. Typically, information sharing or connectivity between the users is provided by a network, which comprises several computers connected together as a group. At least one of the PCs functions as a "server," providing network services to "clients" (other computers) on the network. In this manner, valuable resources, such as programs, information tables, memory, disk space, printers, and the like, may be shared by several users.
Inherent in any multi-user computing system is a basic conflict between data integrity and concurrency, i.e., the need to let many users access the same data simultaneously. To ensure data integrity, such a system could allow only one user to use a data table at any given time, but this would be highly inconvenient to other users. On the other hand, the system could allow anyone on a network to use any table at any time. Such unrestricted access, however, would quickly lead to inconsistencies in the data. The need for insuring data integrity, therefore, must be balanced with the need to provide maximum concurrent access. Thus, a key issue in designing any multi-user application is deciding how to resolve simultaneous requests for the same resources.
The need for concurrency control is perhaps most acute in a multi-user database system, where information is frequently or even constantly being updated by several users. Suppose, for example, that two users are both executing an application that reads a particular value from a database, performs a calculation on the value, and writes a new value back to the database. If this process begins concurrently, both users will read the same database value, e.g., three. Suppose the calculation is to increment the database value by one. After both users have finished, the new value stored in the database will be four. However, the correct value desired is five, since each of the two intended to add one to the value of three. Thus, the concurrent actions of two processes have interfered, leaving incorrect data in the database.
The technique most commonly employed for coordinating processes and controlling access to shared resources is a "lock" mechanism. Without such a scheme, a second user may update an object, thus providing the first user with old data (as in the above example). With locks, objects (e.g., tables, reports, forms, and other resources) are restricted in such a way that interference problems are avoided. This service is most conveniently managed by the network database system, with typically some low-level locking mechanism provided by the operating system. In this manner, multiple users may transparently access the same resources in the same database at the same time, with data integrity fully maintained.
In its simplest form, locking an object prevents other processes or transactions from accessing that object (or portion thereof) until the lock is released. In general, the less that is locked, the greater the potential for concurrency: more processes can simultaneously access the database without encountering each other's locks. If the lock is too weak, however, data integrity may still be compromised. On the other hand, a lock which is too strong unnecessarily restricts others from accessing the locked object. Thus, providing the right type of lock for a user's need is an important consideration.
Two types of locks are fundamental to concurrency: write locks and read locks. Exclusive or write locks allow the user of the lock full access to the locked object. That user holds sole access to the object for reading and changing. While a write lock is in place, no other user can read or access that object. Moreover, no other user can place a write lock on that object (i.e., it has already been locked by another). A shared or read lock, in contrast, allows multiple users to access an object but only guarantees the current state of the object. The lock guarantees that no other user will be granted write access to the object; others may be granted read access, however. With a read lock, therefore, multiple users can view an object of a database; at the same time, the system prevents any changes to that object.
In addition to the locks themselves, there are also interactions between locks, including some locks blocking other locks. For example, a write lock must block a read lock as well as another write lock. A read lock, on the other hand, blocks attempts to write to the object, but it does not block other read locks. If a requested lock is blocked by another, the requestor must wait until that block is removed A system may also provide a "time-out," i.e., a pre-set time limit specifying the maximum time one waits for an object to be unlocked. If a request for a lock fails, the system typically will undo or roll back the current transaction, including releasing other locks held by that process.
Regardless of the type or hierarchy of locks provided, a system must be able to process locks in real-time. In particular, many database systems (e.g., relational DBMSs) are designed to manage multiple short transactions, each occurring on the order of fractions of a second. To accommodate these transactions, locks must be capable of being held for only short periods of time. All the while, the database system must somehow keep track of which objects are locked and what interactions are occurring between the locks.
Possible approaches for a system include maintaining a table of objects which are locked, marking objects which are locked, and storing locked objects in a special area of memory. Of particular interest to the present invention is the first approach which employs "lock tables" for tracking who holds a lock and what kind of lock it is. Commonly, prior art techniques for managing lock files employ an inefficient system open call mechanism. To lock a record in a table, for example, many steps are required: 1) open the lock file, 2) read the entire contents of that file, 3) determine if a conflict of locks exists, and, if not, add a record lock to the lock file, 4) write the file out to physical disk, and 5) close the file. As this approach requires numerous disk input/output (I/O) operations, a hefty performance penalty is incurred. Thus, prior art techniques employing lock files in multi-user environments of even modest size must compromise performance.